source("Scripts/libraries.R")
source("Scripts/variables.R")
source("Scripts/functions.R")

1 Examples of user history

rm(list=ls())
source("Scripts/libraries.R")
source("Scripts/variables.R")
source("Scripts/functions.R")

1.1 Kindara

1.2 Sympto

load(paste0(IO$sympto_data_02_processed,'cycledays.Rdata'), verbose = TRUE)
## Loading objects:
##   cycledays
agg = aggregate(cycle_nb ~ user_id, cycledays,lu)
j = which(agg$cycle_nb >= 50)

user_ids = agg$user_id[j]
rm(j, agg)
for(u in user_ids[1:10]){
    k = which(cycledays$user_id == u)
    plot.tracking.history(d = cycledays[k,], show_goal = TRUE, relative_date = TRUE)
}

rm(u, k)
u = 1226
k = which(cycledays$user_id == u)
plot.tracking.history(d = cycledays[k,], show_goal = TRUE, relative_date = TRUE)

cycledays_sympto_user_history = cycledays[k,]

save(cycledays_sympto_user_history,file = paste0(IO$restricted_figure_data,"history_sympto.Rdata"))

rm(u, k, cycledays_sympto_user_history, cycledays, user_ids)

2 Users demographics

rm(list=ls())
source("Scripts/libraries.R")
source("Scripts/variables.R")
source("Scripts/functions.R")

2.1 Kindara

#load(file = '../../../Apps/Kindara/Analysis/Rdata/Accounts/processed_cleaned_accounts_onefile.Rdata', verbose = TRUE)
# TO DO
#round(mean(accounts$age_registration, na.rm = TRUE), digits = 1)
#round(sd(accounts$age_registration, na.rm = TRUE), digits = 1)
#round(100 - (sum(is.na(accounts$age_registration))/nrow(accounts)*100))
#users_demo_kindara = accounts$age_registration
#save(users_demo_kindara,file = paste0(IO$restricted_figure_data,"users_demo_kindara.Rdata"))
#rm(accounts, users_demo_kindara)

2.2 Sympto

load(paste0(IO$sympto_data_02_processed,'users.Rdata'), verbose = TRUE)
## Loading objects:
##   users
users_demo = users[,c("age_registration","age_now","menarche_year","cm","kg","bmi")]

users_demo$cm_o = users_demo$cm
users_demo$cm[which(users_demo$cm < 100)] = 100 + users_demo$cm[which(users_demo$cm < 100)] 

users_demo$bmi_o = users_demo$bmi
users_demo$bmi = users$kg / ((users_demo$cm/100)^2)


summary(users_demo)
##  age_registration    age_now      menarche_year         cm       
##  Min.   : 0.00    Min.   : 0.00   Min.   : 8.00   Min.   :100.0  
##  1st Qu.:26.00    1st Qu.:29.00   1st Qu.:12.00   1st Qu.:160.0  
##  Median :29.00    Median :33.00   Median :13.00   Median :165.0  
##  Mean   :29.94    Mean   :33.52   Mean   :12.85   Mean   :165.3  
##  3rd Qu.:34.00    3rd Qu.:38.00   3rd Qu.:14.00   3rd Qu.:170.0  
##  Max.   :74.00    Max.   :77.00   Max.   :18.00   Max.   :229.0  
##  NA's   :2570     NA's   :2570    NA's   :2819    NA's   :2735   
##        kg              bmi               cm_o           bmi_o       
##  Min.   : 20.00   Min.   :  7.703   Min.   : 50.0   Min.   : 7.703  
##  1st Qu.: 54.00   1st Qu.: 19.818   1st Qu.:160.0   1st Qu.:19.818  
##  Median : 60.00   Median : 21.631   Median :165.0   Median :21.630  
##  Mean   : 62.23   Mean   : 22.788   Mean   :161.3   Mean   :22.840  
##  3rd Qu.: 67.00   3rd Qu.: 24.342   3rd Qu.:170.0   3rd Qu.:24.314  
##  Max.   :149.00   Max.   :103.939   Max.   :229.0   Max.   :86.565  
##  NA's   :2765     NA's   :2786      NA's   :2735    NA's   :3214
round(apply(users_demo, 2, sd, na.rm = TRUE), digits = 2)
## age_registration          age_now    menarche_year               cm 
##             6.36             6.69             1.61             6.73 
##               kg              bmi             cm_o            bmi_o 
##            13.14             4.76            21.25             5.02
100 - round(apply(users_demo, 2, function(x) sum(is.na(x)))/nrow(users)*100)
## age_registration          age_now    menarche_year               cm 
##               81               81               79               80 
##               kg              bmi             cm_o            bmi_o 
##               80               80               80               76
users_demo_sympto = users_demo
save(users_demo_sympto,file = paste0(IO$restricted_figure_data,"users_demo_sympto.Rdata"))

rm(users, users_demo, users_demo_sympto)